package top.yamhk.agent;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.yamhk.agent.entity.response.MatrixResponse;

import java.util.HashMap;
import java.util.Map;

/**
 * 站点配置控制器
 * 提供主站和副站地址配置，供前端动态获取
 *
 * @author YamHK
 */
@Slf4j
@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/api")
public class SiteConfigController {

    /**
     * 主站点地址
     */
    @Value("${site.config.main-site:https://2025.task2030.xyz/}")
    private String mainSite;

    /**
     * 副站点地址
     */
    @Value("${site.config.backup-site:https://zjnh.yamhk.top/}")
    private String backupSite;

    /**
     * 获取站点配置信息
     * 
     * @return 站点配置信息
     */
    @GetMapping("/site-config")
    public MatrixResponse<Map<String, String>> getSiteConfig() {
        log.info("获取站点配置信息: 主站点={}, 副站点={}", mainSite, backupSite);
        
        Map<String, String> config = new HashMap<>();
        config.put("mainSite", mainSite);
        config.put("backupSite", backupSite);
        
        return MatrixResponse.ok().withData(config);
    }
}